package com.steak.javase.cglib;

import net.sf.cglib.reflect.FastClass;
import net.sf.cglib.reflect.FastMethod;

import java.lang.reflect.InvocationTargetException;

/**
 * 功能说明：CGLib
 * <p>
 * Original @Author: steakliu-刘牌, 2022-10-09  09:27
 * <p>
 * Copyright (C)2020-2022  steakliu All rights reserved.
 */
public class CglibTest {
    public static void main(String[] args) throws InvocationTargetException {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 10; i++) {
            FastClass fastClass = FastClass.create(DemoService.class);
            FastMethod fastMethod = fastClass.getMethod("say", new Class[]{String.class});
            DemoService demoService = new DemoService();
            Object o = fastMethod.invoke(demoService, new Object[]{"mikey"});
            System.out.println(o);
        }
        long end = System.currentTimeMillis();
        System.out.println("cglib cost time " + (end - start));
    }
}
